package logic

import (
	"context"
	"taobao/taobaorpc/taobaorpc"

	"taobao/api/internal/svc"
	"taobao/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShopPerfectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewShopPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShopPerfectLogic {
	return &ShopPerfectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ShopPerfectLogic) ShopPerfect(req *types.ShopPerfectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	perfect, err := l.svcCtx.TaobaoRpc.ShopPerfect(l.ctx, &taobaorpc.ShopPerfectRequest{
		HeadIamge: req.HeadIamge,
		Name:      req.Name,
		Price:     float32(req.Price),
		UserId:    req.UserId,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "完善信息成功",
		Data:    perfect,
	}, nil
}
